/**
 * 订单详情 (OrderDetail) 类。
 * UML 关联: OrderDetail (1) <--> (1) Product
 */
public class OrderDetail {
    private int quantity;
    private Product product; // 关联到唯一的商品项

    public OrderDetail(Product product, int quantity) {
        this.product = product;
        this.quantity = quantity;
    }

    // UML 操作: calculateSubTotal()
    public double calculateSubTotal() {
        return product.getPriceForQuantity(this.quantity);
    }

    // UML 操作: calculateWeight()
    public double calculateWeight() {
        return product.getWeight() * this.quantity;
    }
}